package sivin.uikit.adapter2

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.viewbinding.ViewBinding
import com.bumptech.glide.Glide.init

class SimpleAdapter<E, Binding : ViewBinding>(
    private val bindingInflater: (LayoutInflater, ViewGroup, Boolean) -> Binding,
    private val onViewHolderCreate: ((holder: XViewHolder<Binding>) -> Unit)? = null,
    private val bindData: (holder: XViewHolder<Binding>, item: E, position: Int) -> Unit
) : CommonAdapter<E>() {
    init {
        addItemViewDelegate(object : ItemViewDelegate<E, Binding>(bindingInflater) {
            override fun onViewHolderCreate(holder: XViewHolder<Binding>) {
                onViewHolderCreate?.invoke(holder)
            }

            override fun onBindData(holder: XViewHolder<Binding>, item: E, position: Int) {
                bindData(holder, item, position)
            }

            override fun isForViewType(item: E, position: Int): Boolean {
                return true
            }
        })
    }
}